import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

class compare implements Comparator<Integer> {

    @Override
    public int compare(Integer o1, Integer o2) {
        return o2-o1;
    }

}
public class First {
    public static void main(String[] args) {
        MyPriorityQueue hh = new MyPriorityQueue();//这个中的向上调整，
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        for (int i = 0; i < a.length; i++) {
            hh.push(a[i]);
        }
        hh.heapSort();
        System.out.println(Arrays.toString(hh.array));
    }
    public static void maiqn(String[] args) {
        MyPriorityQueue hh = new MyPriorityQueue();//这个中的向上调整，
        PriorityQueue<Integer> hhh = new PriorityQueue<>();//默认是小根堆
        compare cmp = new compare();
        for (int i = 10; i >0; i--) {
            hhh.offer(i);
            hh.push(i);
        }
        hh.heapSort();//有个错误是因为usesize这个没有随程序的进行而值的减小
        int []  arr = new int[10];
        for (int i = 0; i < 10; i++) {
            arr[i] = hhh.poll();
        }
        System.out.println("hhh"+Arrays.toString(arr));
        System.out.println(hhh);

        System.out.println();
        System.out.println(Arrays.toString(hh.array));
        //System.out.println(Arrays.toString(hh.creatHeap()));
    }
    public static void main1(String[] args) {
        //{ 27,15,19,18,28,34,65,49,25,37 }
//        int[] arr = {27, 15, 19, 18, 28, 34, 65, 49, 25, 37};
        MyPriorityQueue hh = new MyPriorityQueue();
        PriorityQueue<Integer> hhh = new PriorityQueue<>();
//        System.out.println("jj");
//
//        hh.creatHeap(hh.array);
//
////        hh.push(999);
//        for (int i = 1; i < 10; i++) {
//            hh.push(i);
//        }
        int[] array = new int[10];
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }

        hh.creatHeap();
        System.out.println(Arrays.toString(array));
//        hh.poll(hh.array);
//        System.out.println(hh.peek());
    }
}
